/*
 * Copyright (C) 2010 Graham Allan
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package edu.strath.cis.grallan.findbugs.adaptiveranking;

import edu.umd.cs.findbugs.BugCollection;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.ClassAnnotation;
import edu.umd.cs.findbugs.SortedBugCollection;
import edu.umd.cs.findbugs.internalAnnotations.DottedClassName;

/**
 * @author Graham Allan (grallan@cis.strath.ac.uk)
 */
public class AdaptiveRankingTestUtil {

    private static final int IGNORED_PRIORITY = 0;
	public static final double delta = 0.00000001;

	public static BugInstance newBugInstance() {
		return new BugInstance("UUF_UNUSED_FIELD", IGNORED_PRIORITY);
	}
	
	public static BugInstance newBugInClass(@DottedClassName String className) {
		BugInstance bug = newBugInstance();
		bug.add(new ClassAnnotation(className));
		return bug;
	}
	
	public static BugInstance newBugInClass(@DottedClassName String className, String type) {
		BugInstance bug = new BugInstance(type, 0);
		bug.add(new ClassAnnotation(className));
		return bug;
	}
	
	public static BugCollection newCollectionContaining(BugInstance... bugInstances) {
		BugCollection bugCollection = new SortedBugCollection();
		for(BugInstance bug: bugInstances) {
			bugCollection.add(bug);
		}
		return bugCollection;
	}
	
	public static BugCollection newCollectionContaining(Iterable<BugInstance> bugInstances) {
		BugCollection bugCollection = new SortedBugCollection();
		for(BugInstance bug: bugInstances) {
			bugCollection.add(bug);
		}
		return bugCollection;
	}
}
